#!/bin/bash
SERVICE_NAME=${SERVICE_NAME:=sentinel-dashboard}
## Adjust log dir if necessary
LOG_DIR=/opt/logs/8849
## Adjust server port if necessary
SERVER_PORT=${SERVER_PORT:=8849}
NACOS_SERVER_ADDR=${NACOS_SERVER_ADDR:=localhost:8848}

## Create log directory if not existed because JDK 8+ won't do that
mkdir -p $LOG_DIR

## Adjust memory settings if necessary
#export JAVA_OPTS="-Xms2560m -Xmx2560m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1536m -XX:MaxNewSize=1536m -XX:SurvivorRatio=8"

## Only uncomment the following when you are using server jvm
#export JAVA_OPTS="$JAVA_OPTS -server -XX:-ReduceInitialCardMarks"

########### The following is the same for configservice, adminservice, portal ###########
#export JAVA_OPTS="$JAVA_OPTS -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=9 -XX:+DisableExplicitGC -XX:+ScavengeBeforeFullGC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/./urandom"

export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dcsp.sentinel.dashboard.server=localhost:$SERVER_PORT -Dproject.name=$SERVICE_NAME -Dnacos.server-addr=$NACOS_SERVER_ADDR -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/"

PATH_TO_JAR=$SERVICE_NAME".jar"

chmod a+x $SERVICE_NAME".jar"
./$SERVICE_NAME".jar" start


exit 0;
